import com from './addon/com'

var components = com([
	'HeaderLayout',
	'HeaderDock',
	'LayoutMain',
	'LayoutBox',
	'Btn',
	'Icon',
	'FormGroup',
	'FormInput',
	'GridRow',
	'TabsHorizon',
	'TabsItemHorizon'
])

//
new Vue({
	el: '#app',
	components: components,
	methods: {
		goDetail: function(id, date){
			window.location.href = SITE_URL + '/home/get_productdetail/id/' + id + '/date/' +date;//+ '?date=' + this.currentDate;
		},
		cancelOrder: function(id){
			if(confirm('确定取消订单？')){
				$.ajax({
					url: SITE_URL + '/order/cancel' ,
					type: 'post',
					data: {
						orderid: id
					},
					success: function(data){
						alert(data.msg)

								window.location.reload();



					},
					error: function(){
						alert('网络发生错误，请重试');
					}
				});
			}
		},
		submit: function(){

		}
	},
	created: function(){
		if(ORDERS.length <= 0){
			this.empty = true;
		}
	},
	data (){
		var t = [false,false,false,false];
		if(STATE == -1){
			t[0] = true
		} else if(STATE == 0){
			t[1] = true;
		} else if(STATE == 1){
			t[2] = true;
		} else if(STATE == 2){
			t[3] = true;
		} else if(STATE == 3){
			t[4] = true;
		}

		return {
			tabs: t,
			empty: false,
			orders: ORDERS,
			orderstate: [
				'待确认',
				'已确认',
				'已发货'
			]
		}
	}
})
